package com.spddr.pmos.jpa;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Embeddable;

import org.joda.time.DateTime;

@Embeddable
public class DispatchOrderId implements java.io.Serializable {
	private static final long serialVersionUID = 1L;

	private DateTime occur;
	private int type;
	private long psr;

	public DispatchOrderId() {
	}

	public DispatchOrderId(DateTime occur, int type, long psr) {
		this.occur = occur;
		this.type = type;
		this.psr = psr;
	}

	@Column(name = "occur", nullable = false, length = 16)
	@Convert(converter = cn.seqdata.jpa.converter.DateTimeConverter.class)
	public DateTime getOccur() {
		return this.occur;
	}

	public void setOccur(DateTime occur) {
		this.occur = occur;
	}

	@Column(name = "type", nullable = false)
	public int getType() {
		return this.type;
	}

	public void setType(int type) {
		this.type = type;
	}

	@Column(name = "psr", nullable = false)
	public long getPsr() {
		return this.psr;
	}

	public void setPsr(long psr) {
		this.psr = psr;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((occur == null) ? 0 : occur.hashCode());
		result = prime * result + (int) (psr ^ (psr >>> 32));
		result = prime * result + type;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		DispatchOrderId other = (DispatchOrderId) obj;
		if (occur == null) {
			if (other.occur != null)
				return false;
		} else if (!occur.equals(other.occur))
			return false;
		if (psr != other.psr)
			return false;
		if (type != other.type)
			return false;
		return true;
	}
}